home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / TODOLIST.ARJ / TODODLGS.H < prev    next >
C/C++ Source or Header  |  1991-11-11  |  6KB  |  198 lines

  1. #if !defined( __TODODLGS_H )
  2. #define __TODODLGS_H
  3.  
  4. //---------------------------------------------------------------------
  5. //
  6. //  TODODLGS.H
  7. //
  8. //      Copyright (c) 1991 by Borland International
  9. //      All Rights Reserved.
  10. //
  11. //  defines the following classes, which handle all the dialog boxes for
  12. //  the Todo program.
  13. //
  14. //      AboutBox
  15. //
  16. //      FileBox     - provides a basic dialog for selecting a file.
  17. //
  18. //      EditBox     - provides a dialog box for editing an entry in the
  19. //                    Todo list.
  20. //
  21. //---------------------------------------------------------------------
  22.  
  23. #if !defined( __WINDOWS_H )
  24. #include <Windows.h>
  25. #endif  // __WINDOWS_H
  26.  
  27. #if !defined( __DIR_H )
  28. #include <Dir.h>
  29. #endif  // __DIR_H
  30.  
  31. #if !defined( __STRSTREAM_H )
  32. #include <strstream.h>
  33. #endif  // __STRSTREAM_H
  34.  
  35. #if !defined( __TODOWIN_H )
  36. #include "TodoWin.h"
  37. #endif  // __TODOWIN_H
  38.  
  39. #if !defined( __TODOLIST_H )
  40. #include "TodoList.h"
  41. #endif  // __TODOLIST_H
  42.  
  43. //---------------------------------------------------------------------
  44. //
  45. //  class AboutBox
  46. //
  47. //      draws and manages the About dialog.
  48. //
  49. //---------------------------------------------------------------------
  50.  
  51. class AboutBox : public ModalDialog
  52. {
  53.  
  54. public:
  55.  
  56.     AboutBox( HWND );
  57.  
  58. private:
  59.  
  60.     virtual LPSTR getDialogName();
  61.  
  62.     virtual BOOL dispatch( HWND, WORD, WORD, LONG );
  63.  
  64. };
  65.  
  66. //---------------------------------------------------------------------
  67. //
  68. //  class FileBox
  69. //
  70. //      draws and manages a dialog box for selecting a file.
  71. //
  72. //---------------------------------------------------------------------
  73.  
  74. class FileBox : public ModalDialog
  75. {
  76.  
  77. public:
  78.  
  79.     FileBox( HWND, const char *, const char *, const char *, BOOL = TRUE );
  80.  
  81.                                 // constructor for the FileBox.
  82.                                 //
  83.                                 // Arguments:
  84.                                 //
  85.                                 // HWND owner - handle of the owner of
  86.                                 //              this dialog
  87.                                 // const char *c - caption for this dialog
  88.                                 // const char *p - initial path
  89.                                 // const char *s - file spec (wildcards
  90.                                 //                 accepted)
  91.                                 // BOOL me       - indicates whether the
  92.                                 //                 selected file must exist
  93.                                 //                 in order to be valid.
  94.                                 //                 For an input file, this
  95.                                 //                 should be TRUE.  For an
  96.                                 //                 output file it can
  97.                                 //                 be FALSE.
  98.  
  99.  
  100.     const char *getPath();      // after executing run(), this function
  101.                                 // can be called to get the full path
  102.                                 // to the selected file.
  103.  
  104.     virtual WORD run();         // draws the dialog box and handles
  105.                                 // user input
  106.  
  107. protected:
  108.  
  109.     virtual BOOL dispatch( HWND, WORD, WORD, LONG );
  110.  
  111. private:
  112.  
  113.     virtual LPSTR getDialogName();
  114.  
  115.     const char *caption;        // store initial parameter
  116.     const char *iPath;          // store initial parameter
  117.     const char *iSpec;          // store initial parameter
  118.     BOOL mustExist;             // store initial parameter
  119.  
  120.     char path[MAXPATH];         // used internally to keep track of
  121.                                 // current selection
  122.  
  123.     char res[MAXPATH];          // holds the selected path after run()
  124.                                 // has been executed.
  125.  
  126.     void resetDlg( HWND );      // used internally
  127.     void initDlg( HWND );       // used internally
  128.     BOOL flistCmd( HWND, LONG );  // used internally
  129.     BOOL fnameCmd( HWND, LONG );  // used internally
  130.     void okCmd( HWND );         // used internally
  131.     void cancelCmd( HWND );     // used internally
  132.  
  133. };
  134.  
  135. class TodoEntry;                // forward reference
  136.  
  137. //---------------------------------------------------------------------
  138. //
  139. //  class EditBox
  140. //
  141. //      draws and manages a dialog box to edit an entry in the Todo list.
  142. //
  143. //---------------------------------------------------------------------
  144.  
  145. class EditBox : public ModalDialog
  146. {
  147.  
  148. public:
  149.  
  150.     EditBox( HWND, TodoEntry& );
  151.                                 // constructor for the EditBox.
  152.                                 //
  153.                                 // Arguments:
  154.                                 //
  155.                                 // HWND owner - handle of the owner
  156.                                 //              of this dialog
  157.                                 // TodoEntry& td - the entry to be edited
  158.  
  159. private:
  160.  
  161.     virtual LPSTR getDialogName();
  162.  
  163.     virtual BOOL dispatch( HWND, WORD, WORD, LONG );
  164.  
  165.     TodoEntry& current;         // the entry to be edited
  166.  
  167.     int button;                 // current selection among the radio
  168.                                 // buttons that set the priority
  169.  
  170.     void initDlg( HWND );       // used internally
  171.     void checkButton( HWND, WORD );  // used internally
  172.     void okCmd( HWND );         // used internally
  173.     void cancelCmd( HWND );     // used internally
  174. };
  175.  
  176. //---------------------------------------------------------------------
  177. //
  178. //  inline functions
  179. //
  180. //---------------------------------------------------------------------
  181.  
  182. inline AboutBox::AboutBox( HWND hOwner ) : ModalDialog( hOwner )
  183. {
  184. }
  185.  
  186. inline const char *FileBox::getPath()
  187. {
  188.     return res;
  189. }
  190.  
  191. inline EditBox::EditBox( HWND hOwner, TodoEntry& td ) :
  192.     ModalDialog( hOwner ), current( td )
  193. {
  194. }
  195.  
  196. #endif  // __TODODLGS_H
  197.  
  198.